package com.yotoodesign.core.util;

import java.util.Random;

/**
 * 通用工具类
 * @author zhuchuanming
 *
 */
public class CommonUtil {
	/*
	 * 获取指定范围内的不重复的随机数
	 */
	public static int[] rdmInt(int num,int max) {
		int[] intRet = new int[num];
		int intRd = 0; // 存放随机数
		int count = 0; // 记录生成的随机数个数
		int flag = 0; // 是否已经生成过标志
		while (count < num) {
			Random rdm = new Random(System.currentTimeMillis());
			intRd = Math.abs(rdm.nextInt(max)) + 1;
			for (int i = 0; i < count; i++) {
				if (intRet[i] == intRd) {
					flag = 1;
					break;
				} else {
					flag = 0;
				}
			}
			if (flag == 0) {
				intRet[count] = intRd;
				count++;
			}
		}
		return intRet;
	}
}
